$(document).ready(function() {
	var a = 0;
	var b = 0;

	function send() {
		var url_gen = 'req.php?a=' + a + '&b='+ b; 
		$.ajax({
			dataType: 'json',
			type: 'POST',
			url: url_gen,
			success: function(data) {
				if (data.errorr) {
					document.write(data.errorr);
				} else {
					document.write("<table border='1'>");
					for (var i = 0; a <= b; a++, i++)
						document.write( "<tr> <td>" + a + "</td> <td>" + data.arr[i] + "</td> </tr>");
					document.write("</table>");
				}
			} 
		});
	}

	$("#panel button").bind('click', function() {
		a = Math.floor(Math.random() * (10 - 1) + 1);
		b = Math.floor(Math.random() * (10 - 1) + 1);
		send();
	});
});






/*
var a;
var b;

function getXmlHttp() {
	var xmlhttp;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch(e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(E) {
			xmlhttp = false;
		}
	} 
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function send(xmlhttp) {
	var url = 'req.php?a=' + a + '&b='+ b;
	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			if (xmlhttp.status == 200) {
				document.write("<table border='1'>");
				document.write(xmlhttp.responseText)
				document.write("</table>");
			}
		}
	};		
	xmlhttp.send(null);
}

function compute() {
	a = Math.floor(Math.random() * (10 - 1) + 1);
	b = Math.floor(Math.random() * (10 - 1) + 1);
	var request = getXmlHttp();
    send(request);
}
*/